Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 30, 2025

This PR attempts to address Issue #7552 where the settings gear icon and other buttons were not responding to clicks in a freshly installed extension.

Problem

The IconButton component was conditionally setting the onClick handler based on the disabled state:

onClick={!disabled ? onClick : undefined}

This pattern could prevent clicks from being handled properly when the button was not explicitly disabled.

Solution

The fix removes the conditional onClick attachment and relies on the native HTML button behavior where disabled={true} prevents clicks at the browser level:

onClick={onClick}

Testing

  • All existing tests pass (962 passed, 1 skipped)
  • Type checking passes
  • Linting passes

Related Issue

Feedback and guidance are welcome!


Important

Fixes onClick handler in IconButton to always attach, relying on native disabled behavior to prevent clicks.

This description was created by Ellipsis for ac5775c. You can customize this summary. It will automatically update as commits are pushed.

The IconButton component was conditionally setting the onClick handler
based on the disabled state, which could prevent clicks from being
handled properly when onClick was undefined. The button now always
passes through the onClick handler and relies on the disabled attribute
to prevent clicks when disabled.

Fixes #7552
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 30, 2025 08:35
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Aug 30, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code because apparently I trust no one, not even myself.

)}
disabled={disabled}
onClick={!disabled ? onClick : undefined}
onClick={onClick}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks correct - removing the conditional onClick handler and relying on the native button's disabled attribute is the right approach. This simplifies the code and fixes the issue where buttons weren't responding to clicks.

A few observations for future consideration:

  1. Would it be worth adding tests for this component to prevent regression?
  2. I noticed there's another IconButton in webview-ui/src/components/common/IconButton.tsx - is this duplication intentional?
  3. Consider adding a comment explaining why conditional onClick isn't needed with the disabled attribute.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 30, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Sep 2, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 2, 2025
@daniel-lxs daniel-lxs closed this Sep 2, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 2, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Sep 2, 2025
@daniel-lxs daniel-lxs deleted the fix/icon-button-onclick-handler-7552 branch September 2, 2025 16:52
@charly1
Copy link

charly1 commented Oct 2, 2025

This problem is still here in version 3.28.14...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Needs Preliminary Review size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Freshly installed extension and unable to open Settings in VSCode

5 participants